package tech.wangpai.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import tech.wangpai.domain.User;

import javax.transaction.Transactional;
import java.util.List;

@Repository
public interface UserMapper extends JpaRepository<User, String> {

    List<User> findUserByUsername(String username);

    User findUserByUserId(String userId);

    @Transactional
    @Modifying
    @Query(nativeQuery= true,value="UPDATE sys_user SET age = :age WHERE user_id = :userId")
    void updateUserAgeById(String userId, Integer age);


//    void addUser(User user);
//
//    void delUserById(String userId);
//
//    void updateUserById(String userId, User user);
//
//    void updateUserAgeById( String userId, Integer age);
}
